class_name Chessboard

static var BOARD_SIZE = 6

# 记录棋盘状态
static var board_state
enum STATE {IDLE, PLAYER_MOVE, CARD_ACTION, BLOCK}

# 记录棋盘数组
static var board_array = []
static var focus_card = null

# 记录player状态
static var player_list = []
static var focus_player = null

# 记录enemy状态
static var enemy_list = []
static var focus_enemy = null

# 记录鼠标悬停在哪一格上
static var hover_grid_coord

static func _init():
	# 初始化棋盘数组
	for i in range(BOARD_SIZE):
		var new_line = []
		for j in range(BOARD_SIZE):
			new_line.append(null)
		board_array.append(new_line)
	board_state = STATE.IDLE

# 检查是否可以执行移动，目标位置是否被block
static func can_move_array(to_coord):
	# 目标位置上的棋子
	var piece_in_to_coord = board_array[to_coord[0]][to_coord[1]]
	# 如果目标位置已经有block类型的棋子
	if piece_in_to_coord != null and piece_in_to_coord.is_block:
		print("Grid has been taken")
		return false
	else:
		return true

# 执行棋子移动，更新棋盘
static func move_array(character, from_coord, to_coord):
	# print(character)
	if len(from_coord) != 0: # 如果没有from，说明是初次放到棋盘上
		Chessboard.board_array[from_coord[0]][from_coord[1]] = null
	Chessboard.board_array[to_coord[0]][to_coord[1]] = character
